<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>BMI</title>
	</head>
	<body>
		<p>体重KG：</p>
		<input id="n1" type="text"/>
		    <p>身高M：</p>
		<input id="n2" type="text"/>
				<br/>
		        <br/>
		        <input id="btn1" type="button" value="求BMI"  onclick="BMI()"/>
		<script>
			function  BMI(){
			var num1=document.getElementById('n1');
			var num2=document.getElementById('n2');
			var result=Number(num1.value)/(Number(num2.value)*Number(num2.value));
			if(result<18.5){
				alert("您的体质指数为："+result.toFixed(2)+"过轻");
			}else if(result<=23.9){
				alert("您的体质指数为："+result.toFixed(2)+"正常");
			}else if(result<=27){
				alert("您的体质指数为："+result.toFixed(2)+"过重");
			}else if(result<=32){
				alert("您的体质指数为："+result.toFixed(2)+"肥胖");
			}else{
				alert("您的体质指数为："+result.toFixed(2)+"非常肥胖");
			}
			}
		        
		
		</script>
		
	</body>
</html>
